package com.ruogu.codegeneration.config;

import dev.langchain4j.model.chat.StreamingChatModel;
import dev.langchain4j.model.openai.OpenAiStreamingChatModel;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ruogu
 */
@Configuration
@ConfigurationProperties(prefix = "langchain4j.open-ai.chat-model")
@Data
public class ReasoningStreamingChatModelConfig {

    /**
     * apiKey
     */
    private String apiKey;

    /**
     * baseUrl
     */
    private String baseUrl;

    /**
     * 推理流式模型(用于Vue项目生成,带工具调用)
     *
     * @return 推理流式模型
     */
    @Bean
    public StreamingChatModel reasoningStreamingChatModel() {
        // 测试使用
        final String modelName = "deepseek-chat";
        final int maxTokens = 8192;

        // 生产使用
//        final String modelName = "deepseek-reasoner";
//        final int maxTokens = 8192;

        return OpenAiStreamingChatModel.builder()
                .apiKey(apiKey)
                .baseUrl(baseUrl)
                .modelName(modelName)
                .maxTokens(maxTokens)
                .logRequests(true)
                .logResponses(true)
                .build();
    }


}
